<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@include file="/WEB-INF/webpage/common/taglibs.jspf"%>
<!DOCTYPE html>
<html>
<head>
  <title><spring:message code="cc.humiture.title" /></title>
  <meta name="decorator" content="grid-select"/>
</head>
<body title="<spring:message code="cc.humiture.title" />">
<grid:grid id="ccHumitureGridId" url="${adminPath}/cc/device/humiture/humitureAjaxList?sn=${sn}" multiselect="false" sortname="collectTime" sortorder="desc">
    <grid:column label="cc.humiture.deviceId" name="deviceSn"/>
    <grid:column label="cc.humiture.collectTime" name="collectTime" query="true" queryMode="dateTime" condition="between"/>
    <grid:column label="cc.humiture.temperature" name="temperature" />
    <grid:column label="cc.humiture.semaphore" name="semaphore" />
    <grid:column label="cc.humiture.electric" name="electric" />
    <grid:column label="cc.humiture.humidity" name="humidity" />

    <grid:toolbar title="导出Excel" icon="fa-file-text-o" onclick="expExcel()"/>
    <grid:toolbar title="导出PDF" icon="fa-file-text-o" onclick="expPDF()"/>
    <grid:toolbar title="设备全导出EXCEL" icon="fa-file-text-o" onclick="expAllExcel()"/>
    <grid:toolbar title="设备全导出PDF" icon="fa-file-text-o" onclick="expAllPDF()"/>
    <grid:toolbar function="search"/>
    <grid:toolbar function="reset"/>
</grid:grid>

<html:js name="laydate" />

<script type="text/javascript">
    /**
     * 获取查询参数
     */
    function getQueryParams() {
        var queryParams = {};
        var queryFields=$('#queryFields').val();
        queryParams['queryFields'] = queryFields;
        //普通的查询
        $("#ccHumitureGridIdGridQuery").find(":input").each(function() {
            var val = $(this).val();
            if (queryParams[$(this).attr('name')]) {
                val = queryParams[$(this).attr('name')] + "," + $(this).val();
            }
            queryParams[$(this).attr('name')] = val;
        });
        // 普通的查询
        $("#ccHumitureGridIdGridQuery").find(":input").each(function() {
            var condition = $(this).attr('condition');
            if (!condition) {
                condition = "";
            }
            var key = "query." + $(this).attr('name') + "||" + condition;
            queryParams[key] = queryParams[$(this).attr('name')];
        });

        return queryParams;
    }

    /**
     * 导出Excel
     */
    function expExcel() {
        var queryParams = getQueryParams();
        var url = "${adminPath}/cc/device/humiture/expExcel?sn=${sn}&collectTime=" + queryParams.collectTime;
        window.location.href= url;
    }

    /**
     * 导出PDF
     */
    function expPDF() {
        var queryParams = getQueryParams();
        var url = "${adminPath}/cc/device/humiture/expPDF?sn=${sn}&collectTime=" + queryParams.collectTime;
        window.location.href= url;
    }

    /**
     * 导出Excel
     */
    function expAllExcel() {
        var queryParams = getQueryParams();
        if (queryParams.collectTime == undefined || queryParams.collectTime == '') {
            top.layer.alert('请选中导出时间!', {icon: 0, title:'警告'});
            return;
        }
        var url = "${adminPath}/cc/device/humiture/expAllExcel?collectTime=" + queryParams.collectTime;
        window.location.href= url;
    }

    /**
     * 导出PDF
     */
    function expAllPDF() {
        var queryParams = getQueryParams();
        if (queryParams.collectTime == undefined || queryParams.collectTime == '') {
            top.layer.alert('请选中导出时间!', {icon: 0, title:'警告'});
            return;
        }
        var url = "${adminPath}/cc/device/humiture/expAllPDF?collectTime=" + queryParams.collectTime;
        window.location.href= url;
    }
</script>

</body>
</html>
